
//引入网络库
import { get, post } from "../../util/util.js"
// 获取全局应用程序实例对象
var app = getApp();

// 创建页面实例对象
Page({
  /** 
   * 页面名称 
   */
  name: "edityirendetail",
  /**
   * 页面的初始数据
   */

  data: {
    uid: '',
    bgImg: '',
    headImg: '',
    selected1: true,
    selected2: false,
    selected3: false,
    selected4: false,
    defaulImg: "http://wolaimage-10029986.image.myqcloud.com/1-2016051421050035278.png",
    imgs: [],
    experience: [],
    //基本信息    
    // sex: "1",
    realNameStr: '',
    // numberStr: '',
    nameStr: '',
    weightStr: '',
    birthStr: '',
    // jiguanStr: '',
    changzhuStr: '',
    schoolStr: '',
    skillStr: '',
    introStr: '',
    //性别
    currentItemSex: '',
    sexList: [],
    sexKey: '',
    sexArr: [],
    //身高
    currentItemSg: '',
    heightList: [],
    heightKey: '',
    heightArr: [],
    //年龄段
    currentItemNld: '',
    age_groupList: [],
    age_groupKey: '',
    age_groupArr: [],
    //体型
    currentItemTx: '',
    shapeList: [],
    shapeKey: '',
    shapeArr: [],
    //个人特征 
    skillSize: 1,
    skillKey: '',
    skillArr: [],
    skill: '',
    //特长
    featureSize: 1,
    featureKey: '',
    featureArr: [],
    //语言
    languageSize: 1,
    languageKey: '',
    languageArr: [],
    //颜值
    faceSize: 1,
    faceKey: '',
    faceArr: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad() {
  },
  onLoad: function (o) {
    var that = this;
    that.setData({
      uid: o.uid,
    })
    //图片
    post("/actor/getPhoto", { uid: o.uid }).then(data => {
      that.setData({
        imgs: data.data,
      })

    })
    //视频
    post("/actor/getIntroVideo", { touid: o.uid }).then(data => {
      that.setData({
        introVideo: data.data,
      })
    })
    //演绎经历 
    post("/actor/getExperience", { uid: o.uid }).then(data => {
      that.setData({
        experience: data.data,
      })
    })
    //艺人配置
    post("/tag/getConfig", {}).then(data => {
      //性别
      var sexData = [];
      var sexStr = [];
      for (var key in data.data.sex) {
        sexData.push(key);
        sexStr.push(data.data.sex[key]);
      }
      //身高
      var heightData = [];
      var heightStr = [];
      for (var key in data.data.height) {
        heightData.push(key);
        heightStr.push(data.data.height[key]);
      }
      //年龄段   
      var age_groupData = [];
      var age_groupStr = [];
      for (var key in data.data.age) {
        age_groupData.push(key);
        age_groupStr.push(data.data.age[key]);
      }
      // 体型
      var shapeData = [];
      var shapeStr = [];
      for (var key in data.data.shape) {
        shapeData.push(key);
        shapeStr.push(data.data.shape[key]);
      }




      // //个人特征  
      // var skillData = [];
      // var skillStr = [];
      // if (that.data.sex == '1') {//男
      //   for (var keyItem in data.data.skill[1]) {
      //     skillData.push(keyItem);
      //     skillStr.push(data.data.skill[1][keyItem]);
      //   }
      // } else if (that.data.sex == '2'){
      //   for (var keyItem in data.data.skill[2]) {
      //     skillData.push(keyItem);
      //     skillStr.push(data.data.skill[2][keyItem]);
      //   }
      // }
      // var skillJson = [];
      // for (var i = 0; i < skillStr.length; i++) {
      //   var j = {};
      //   j.val = skillData[i];
      //   j.name = skillStr[i];
      //   j.value = i;
      //   j.checked = false;
      //   skillJson.push(j);
      // }

      //特长  
      var featureData = [];
      var featureStr = [];
      for (var key in data.data.feature) {
        featureData.push(key);
        featureStr.push(data.data.feature[key]);
      }
      var featureJson = [];
      for (var i = 0; i < featureStr.length; i++) {
        var j = {};
        j.val = featureData[i];
        j.name = featureStr[i];
        j.value = i;
        j.checked = false;
        featureJson.push(j);
      }

      //语言  
      var languageData = [];
      var languageStr = [];
      for (var key in data.data.language) {
        languageData.push(key);
        languageStr.push(data.data.language[key]);
      }
      var languageJson = [];
      for (var i = 0; i < languageStr.length; i++) {
        var j = {};
        j.val = languageData[i];
        j.name = languageStr[i];
        j.value = i;
        j.checked = false;
        languageJson.push(j);
      }
      //颜值  
      var faceData = [];
      var faceStr = [];
      for (var key in data.data.face) {
        faceData.push(key);
        faceStr.push(data.data.face[key]);
      }
      var faceJson = [];
      for (var i = 0; i < faceStr.length; i++) {
        var j = {};
        j.val = faceData[i];
        j.name = faceStr[i];
        j.value = i;
        j.checked = false;
        faceJson.push(j);
      }

      that.setData({
        sexList: sexData,
        sexArr: sexStr,

        heightList: heightData,
        heightArr: heightStr,

        shapeList: shapeData,
        shapeArr: shapeStr,

        age_groupList: age_groupData,
        age_groupArr: age_groupStr,

        // skillArr: skillJson,
        skill: JSON.stringify(data.data.skill),

        featureArr: featureJson,

        languageArr: languageJson,

        faceArr: faceJson,
      })
      //获取剧组详情
      post("/actor/getBaseInfo", { touid: o.uid }).then(data => {

        //个人特征  
        var skillData = [];
        var skillStr = [];
        var skillJson = [];
        if (data.data.sex == 1) {//男
          for (var keyItem in JSON.parse(that.data.skill)[1]) {
            skillData.push(keyItem);
            skillStr.push(JSON.parse(that.data.skill)[1][keyItem]);
          }
        } else if (data.data.sex == 2) {
          for (var keyItem in JSON.parse(that.data.skill)[2]) {
            skillData.push(keyItem);
            skillStr.push(JSON.parse(that.data.skill)[2][keyItem]);
          }
        }

        for (var i = 0; i < skillStr.length; i++) {
          var j = {};
          j.val = skillData[i];
          j.name = skillStr[i];
          j.value = i;
          j.checked = false;
          skillJson.push(j);
        }
        that.setData({
          skillArr: skillJson,
        })

        if (data.data.sex_name != "") {
          var sex = data.data.sex_name;
          for (var i = 0; i < that.data.sexArr.length; i++) {
            if (that.data.sexArr[i] == sex) {
              that.setData({
                currentItemSg: i,
                sexKey: that.data.sexList[i],
              })
            }
          }
        }

        if (data.data.height_group_name != "") {
          var height = data.data.height_group_name;
          for (var i = 0; i < that.data.heightArr.length; i++) {
            if (that.data.heightArr[i] == height) {
              that.setData({
                currentItemSg: i,
                heightKey: that.data.heightList[i],
              })
            }
          }
        }
   
        if (data.data.shape_group_name != "") {
          var shape = data.data.shape_group_name;
          for (var i = 0; i < that.data.shapeArr.length; i++) { 
            if (that.data.shapeArr[i] == shape) { 
              that.setData({
                // currentItemTx: i,
                // shapekey: String(that.data.shapeList[i]),

                currentItemTx: i,
                shapeKey: that.data.shapeList[i], 
              })
            }
          }
        }

        if (data.data.age_group_name != "") {
          var age = data.data.age_group_name;
          for (var i = 0; i < that.data.age_groupArr.length; i++) {
            if (that.data.age_groupArr[i] == age) {
              that.setData({
                currentItemNld: i,
                age_groupKey: that.data.age_groupList[i],
              })
            }
          }
        }

        if (data.data.face_group != null) {
          var arrFace = [];
          var oldFace = that.data.faceArr;
          arrFace = data.data.face_group;
          for (var i = 0; i < arrFace.length; i++) {
            for (var j = 0; j < oldFace.length; j++) {
              if (arrFace[i].name == oldFace[j].name) {
                oldFace[j].checked = true;
                that.setData({
                  faceArr: oldFace
                })
              }
            }
          }
        }

        if (data.data.skill_group != null) {
          var arrSkill = [];
          var oldSkill = that.data.skillArr;
          arrSkill = data.data.skill_group;
          for (var i = 0; i < arrSkill.length; i++) {
            for (var j = 0; j < oldSkill.length; j++) {
              if (arrSkill[i].name == oldSkill[j].name) {
                oldSkill[j].checked = true;
                that.setData({
                  skillArr: oldSkill
                })
              }
            }
          }
        }

        if (data.data.feature_group != null) {
          var arrFeature = [];
          var oldFeature = that.data.featureArr;
          arrFeature = data.data.feature_group;
          for (var i = 0; i < arrFeature.length; i++) {
            for (var j = 0; j < oldFeature.length; j++) {
              if (arrFeature[i].name == oldFeature[j].name) {
                oldFeature[j].checked = true;
                that.setData({
                  featureArr: oldFeature
                })
              }
            }
          }
        }

        if (data.data.language_group != null) {
          var arrLanguage = [];
          var oldLanguage = that.data.languageArr;
          arrLanguage = data.data.language_group;
          for (var i = 0; i < arrLanguage.length; i++) {
            for (var j = 0; j < oldLanguage.length; j++) {
              if (arrLanguage[i].name == oldLanguage[j].name) {
                oldLanguage[j].checked = true;
                that.setData({
                  languageArr: oldLanguage
                })
              }
            }
          }
        }

        that.setData({
          bgImg: data.data.bgimg,
          headimg: data.data.headimg,
          sex: data.data.sex,
          realNameStr: data.data.realname,
          // numberStr: data.data.idno,
          nameStr: data.data.stage_name,
          weightStr: data.data.weight,
          birthStr: data.data.birthday,
          // jiguanStr: data.data.native_place,
          changzhuStr: data.data.area,
          schoolStr: data.data.grad_school,
          skillStr: data.data.school_major,
          introStr: data.data.intro,
        })
      })
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  delYyjl: function (event) {
    var that = this;
    var index = parseInt(event.currentTarget.dataset.index);
    console.log("是否删除演艺经历？" + index);
    wx.showModal({
      title: '提示',
      content: '是否删除演艺经历？',
      success: function (res) {
        if (res.confirm) {
          var dataList = [];
          wx.showLoading({
            title: '处理中',
          })
          dataList = JSON.parse(JSON.stringify(that.data.experience));
          post("/actor/delExperience", { uid: that.data.uid, id: dataList[index].id }).then(data => {
            console.log("delExperience======" + data.data);
            //演绎经历 
            post("/actor/getExperience", { uid: that.data.uid }).then(data => {
              console.log("-获取艺人资料页演绎经历列表====getExperience==" + JSON.stringify(data.data));
              wx.hideLoading();
              that.setData({
                experience: data.data,
              })
            })
          })
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
  },

  addYyjl: function (event) {
    var that = this;
    var uid = that.data.uid;
    console.log("用户跳转传值===" + uid);
    wx.navigateTo({
      url: '../addyyjl/addyyjl?uid=' + uid,
    })
  },

  videoUpLoad: function (event) {
    var that = this;
    wx.showLoading({
      title: '处理中',
    })
    wx.chooseVideo({
      count: 1, // 默认9  
      sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有  
      sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有  
      success: function (res) {
        // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片  
        var tempFilePaths = res.tempFilePath;
        console.log('用户id' + that.data.uid);
        wx.uploadFile({
          url: 'https://www.sc-xhzt.com/api/video/upload',
          filePath: tempFilePaths,
          name: 'file',
          header: {
            "Content-Type": "multipart/form-data",
            'accept': 'application/json',
          },
          formData: {
            'title': '我是开发测试视频1111',
            'type': 3,
            'extid': 1,
            'file': tempFilePaths,
            'uid': that.data.uid,
          },
          success: function (res) {
            wx.hideLoading();
            var data = res.data;
            console.log('data视频上传成功' + data);
            wx.showToast({
              title: '上传成功',
              icon: 'success',
              duration: 1200
            })
          },
          fail: function (res) {
            wx.hideLoading();
            console.log('上传失败' + res.data);
            wx.showToast({
              title: '上传失败',
              icon: 'success',
              duration: 1200
            })
          },
        })
      }
    })
  },
  imgUpLoad: function (event) {
    var that = this;
    wx.chooseImage({
      count: 1, // 默认9  
      sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有  
      sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有  
      success: function (res) {
        // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片  
        var tempFilePaths = res.tempFilePaths;
        console.log('图片路径' + tempFilePaths[0]);
        wx.uploadFile({
          url: 'https://www.sc-xhzt.com/api/image/upload',
          filePath: tempFilePaths[0],
          name: 'file',
          header: {
            "Content-Type": "multipart/form-data",
            'accept': 'application/json',
          },
          formData: {
            'file': tempFilePaths[0],
            'uid': 1,
          },
          success: function (res) {
            let json = res.data.trim();
            let arr = JSON.parse(json);
            wx.showLoading({
              title: '处理中',
            })
            //图片 addPhoto arr.data.url
            post("/actor/addPhoto", { uid: that.data.uid, imgurl: arr.data.url }).then(data => {
              post("/actor/getPhoto", { uid: that.data.uid }).then(data => {
                // console.log("-获取艺人资料页照片列表====getPhoto==" + data.data);
                wx.hideLoading();
                that.setData({
                  imgs: data.data,
                })
                wx.showToast({
                  title: '上传成功',
                  icon: 'success',
                  duration: 1200
                })
              })
            })

          },
          fail: function (res) {
            wx.hideLoading();
            console.log('上传失败' + res.data);
            wx.showToast({
              title: '上传失败',
              icon: 'success',
              duration: 1200
            })
          },
        })
      }
    })
  },

  /**
   * 图片删除
   */
  imgYu: function (event) {
    var that = this;
    var index = parseInt(event.currentTarget.dataset.index);
    console.log("是否删除照片？" + index);
    wx.showModal({
      title: '提示',
      content: '是否删除照片？',
      success: function (res) {
        if (res.confirm) {
          wx.showLoading({
            title: '处理中',
          })
          var dataList = [];
          dataList = JSON.parse(JSON.stringify(that.data.imgs));
          post("/actor/delPhoto", { uid: that.data.uid, id: dataList[index].id }).then(data => {
            console.log("delPhoto======" + data.data);
            //图片
            post("/actor/getPhoto", { uid: that.data.uid }).then(data => {
              wx.hideLoading();
              that.setData({
                imgs: data.data,
              })
            })
          })
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
  },

  /**
   * 监听日期picker选择器
   */
  listenerDatePickerSelected: function (e) {
    var that = this;
    that.setData({
      birthStr: e.detail.value
    })
  },

  selected1: function (e) {
    this.setData({
      selected1: true,
      selected2: false,
      selected3: false,
      selected4: false
    })
  },
  selected2: function (e) {
    this.setData({
      selected2: true,
      selected1: false,
      selected3: false,
      selected4: false
    })
  },
  selected3: function (e) {
    this.setData({
      selected3: true,
      selected2: false,
      selected1: false,
      selected4: false
    })
  },
  selected4: function (e) {
    this.setData({
      selected4: true,
      selected2: false,
      selected3: false,
      selected1: false
    })
  },


  //真实姓名 
  realNameInput: function (e) {
    this.setData({
      realNameStr: e.detail.value
    })
  },
  // //身份证号   
  // numberInput: function (e) {
  //   this.setData({
  //     numberStr: e.detail.value
  //   })
  // },
  //艺名 
  nameInput: function (e) {
    this.setData({
      nameStr: e.detail.value
    })
  },
  weightInput: function (e) {
    this.setData({
      weightStr: e.detail.value
    })
  },
  // birthInput: function (e) {
  //   this.setData({
  //     birthStr: e.detail.value
  //   })
  // },
  // //籍贯  
  // jiguanInput: function (e) {
  //   this.setData({
  //     jiguanStr: e.detail.value
  //   })
  // },
  //常住地 
  changzhuInput: function (e) {
    this.setData({
      changzhuStr: e.detail.value
    })
  },
  //学校 
  schoolInput: function (e) {
    this.setData({
      schoolStr: e.detail.value
    })
  },
  //专业 
  skillInput: function (e) {
    this.setData({
      skillStr: e.detail.value
    })
  },
  //个人简介
  introInput: function (e) {
    this.setData({
      introStr: e.detail.value
    })
  },
  /**
     * 获取点击 性别 字段
     */
  getSex: function (e) {
    var that = this;
    var index = parseInt(e.currentTarget.dataset.index);

    that.setData({
      currentItemSex: index,
      sexKey: that.data.sexList[index],
    })

    //个人特征  
    var skillData = [];
    var skillStr = [];
    var skillJson = [];
    if (that.data.sexList[index] == 1) {//男
      for (var keyItem in JSON.parse(that.data.skill)[1]) {
        skillData.push(keyItem);
        skillStr.push(JSON.parse(that.data.skill)[1][keyItem]);
      }
    } else if (that.data.sexList[index] == 2) {
      for (var keyItem in JSON.parse(that.data.skill)[2]) {
        skillData.push(keyItem);
        skillStr.push(JSON.parse(that.data.skill)[2][keyItem]);
      }
    }

    for (var i = 0; i < skillStr.length; i++) {
      var j = {};
      j.val = skillData[i];
      j.name = skillStr[i];
      j.value = i;
      j.checked = false;
      skillJson.push(j);
    }
    that.setData({
      skillArr: skillJson,
    })
  },
  /**
   * 获取点击 身高 字段
   */
  getSg: function (e) {
    var that = this;
    var index = parseInt(e.currentTarget.dataset.index);

    that.setData({
      currentItemSg: index,
      heightKey: that.data.heightList[index],
    })
  },
  /**
    * 获取点击 体型 字段
    */
  getTx: function (e) {
    var that = this;
    var index = parseInt(e.currentTarget.dataset.index);
    console.log("体型选择" + that.data.shapeList[index]);
    that.setData({
      currentItemTx: index,
      shapeKey: that.data.shapeList[index], 
    })
  },

  /**
  * 获取点击 年龄段 字段
  */
  getNld: function (e) {
    var that = this;
    var index = parseInt(e.currentTarget.dataset.index);
    console.log("年龄段选择" + that.data.age_groupList[index]);
    that.setData({
      currentItemNld: index,
      age_groupKey: that.data.age_groupList[index],
    })
  },
  /**
  * 获取点击 特征 字段
  */
  getTz: function (e) {
    var that = this;
    var skillShenGao = that.data.skillArr;
    var size = that.data.skillSize;
    var index = parseInt(e.currentTarget.dataset.index);
    console.log(that.data.skillArr[index].val + "特征选择" + that.data.skillArr[index].checked);
    if (skillShenGao[index].checked) {
      size--;
      skillShenGao[index].checked = false;
    } else {
      if (size <= 5) {
        size++;
        skillShenGao[index].checked = true;
      } else {
        wx.showModal({
          title: '提示',
          content: '亲~标签不能超过5个哟',
          showCancel: false, //不显示取消按钮
          confirmText: '确定'
        })
      }
    }
    that.setData({
      skillArr: skillShenGao,
      skillSize: size,
    })
  },

  /**
* 获取点击 特长 字段
*/
  getTc: function (e) {
    var that = this;
    var featureShenGao = that.data.featureArr;
    var size = that.data.featureSize;
    var index = parseInt(e.currentTarget.dataset.index);
    console.log(that.data.featureArr[index].val + "特长选择" + that.data.featureArr[index].checked);
    if (featureShenGao[index].checked) {
      size--;
      featureShenGao[index].checked = false;
    } else {
      if (size <= 5) {
        size++;
        featureShenGao[index].checked = true;
      } else {
        wx.showModal({
          title: '提示',
          content: '亲~标签不能超过5个哟',
          showCancel: false, //不显示取消按钮
          confirmText: '确定'
        })
      }
    }
    that.setData({
      featureArr: featureShenGao,
      featureSize: size,
    })
  },
  /**
* 获取点击 语言 字段
*/
  getYy: function (e) {
    var that = this;
    var languageShenGao = that.data.languageArr;
    var size = that.data.languageSize;
    var index = parseInt(e.currentTarget.dataset.index);
    console.log(that.data.languageArr[index].val + "语言选择" + that.data.languageArr[index].checked);
    if (languageShenGao[index].checked) {
      size--;
      languageShenGao[index].checked = false;
    } else {
      if (size <= 5) {
        size++;
        languageShenGao[index].checked = true;
      } else {
        wx.showModal({
          title: '提示',
          content: '亲~标签不能超过5个哟',
          showCancel: false, //不显示取消按钮
          confirmText: '确定'
        })
      }
    }
    that.setData({
      languageArr: languageShenGao,
      languageSize: size,
    })
  },

  /**
* 获取点击 颜值 字段
*/
  getYz: function (e) {
    var that = this;
    var faceShenGao = that.data.faceArr;
    var size = that.data.faceSize;
    var index = parseInt(e.currentTarget.dataset.index);
    console.log(that.data.faceArr[index].val + "颜值选择" + that.data.faceArr[index].checked);
    if (faceShenGao[index].checked) {
      size--;
      faceShenGao[index].checked = false;
    } else {
      if (size <= 5) {
        size++;
        faceShenGao[index].checked = true;
      } else {
        wx.showModal({
          title: '提示',
          content: '亲~标签不能超过5个哟',
          showCancel: false, //不显示取消按钮
          confirmText: '确定'
        })
      }
    }
    that.setData({
      faceArr: faceShenGao,
      faceSize: size,
    })
  },
  yirenSub: function () {
    var that = this;
    var yanzhi = [];
    for (var i = 0; i < that.data.faceArr.length; i++) {
      if (that.data.faceArr[i].checked) {
        yanzhi.push(parseInt(that.data.faceArr[i].val));
      }
    }
    var tezheng = [];
    for (var i = 0; i < that.data.skillArr.length; i++) {
      if (that.data.skillArr[i].checked) {
        tezheng.push(parseInt(that.data.skillArr[i].val));
      }
    }
    console.log("特征传递参数=======" + JSON.stringify(tezheng));
    var techang = [];
    for (var i = 0; i < that.data.featureArr.length; i++) {
      if (that.data.featureArr[i].checked) {
        techang.push(parseInt(that.data.featureArr[i].val));
      }
    }
    console.log("特长传递参数=======" + JSON.stringify(techang));
    var yuyan = [];
    for (var i = 0; i < that.data.languageArr.length; i++) {
      if (that.data.languageArr[i].checked) {
        yuyan.push(parseInt(that.data.languageArr[i].val));
      }
    }
    console.log("语言传递参数=======" + JSON.stringify(yuyan));
    var param = {};
    // param.role = 2;
    param.uid = that.data.uid;
    if (that.data.realNameStr != "") {
      param.realname = that.data.realNameStr;
    }
    if (that.data.weightStr != "") {
      param.weight = parseInt(that.data.weightStr);
    }

    // if (that.data.numberStr != "") {
    //   param.idno = that.data.numberStr;
    // }
    if (that.data.introStr != "") {
      param.intro = that.data.introStr;
    }
    if (that.data.nameStr != "") {
      param.stage_name = that.data.nameStr;
    }
    if (that.data.birthStr != "") {
      param.birthday = that.data.birthStr;
    }
    // if (that.data.sex != "") {
    //   param.sex = that.data.sex;
    // }
    if (that.data.sexKey != "") {
      param.sex = parseInt(that.data.sexKey);
    }
    // if (that.data.jiguanStr != "") {
    //   param.native_place = that.data.jiguanStr;
    // }
    if (that.data.changzhuStr != "") {
      param.area = that.data.changzhuStr;
    }
    if (that.data.schoolStr != "") {
      param.grad_school = that.data.schoolStr;
    }
    if (that.data.skillStr != "") {
      param.school_major = that.data.skillStr;
    }

    // if (that.data.shapeKey != '') {
      param.shape_group = parseInt(that.data.shapeKey); //
    // }
    if (that.data.age_groupKey != "") {
      param.age_group = parseInt(that.data.age_groupKey);//
    }
    if (that.data.heightKey != "") {
      param.height_group = parseInt(that.data.heightKey);//age_group
    }
    if (yanzhi.length > 0) {
      param.face_group = JSON.stringify(yanzhi);
    }
    if (techang.length > 0) {
      param.feature_group = JSON.stringify(techang);
    }
    if (tezheng.length > 0) {
      param.skill_group = JSON.stringify(tezheng);
    }
    if (yuyan.length > 0) {
      param.language_group = JSON.stringify(yuyan);
    }

    if (that.data.bgImg != '') {
      param.bgimg = that.data.bgImg;
    }

    if (that.data.headimg != '') {
      param.headimg = that.data.headimg;
    }

    post("/actor/modifyBaseInfo", param).then(data => {
      wx.showLoading({
        title: '正在提交',
      })
      console.log('提交认证====================' + data.data);
      if (data.code == 0) {
        wx.hideLoading();
        wx.showModal({
          title: '提示',
          content: '基本信息修改已成功提交',
          showCancel: false, //不显示取消按钮
          confirmText: '确定'
        })
      } else {
        wx.hideLoading();
        wx.showModal({
          title: '提示',
          content: data.msg,
          showCancel: false, //不显示取消按钮
          confirmText: '确定'
        })
      }
    })

  },
  //图片上传1
  uploadImg1: function (e) {
    var that = this;
    wx.chooseImage({
      count: 1, // 默认9  
      sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有  
      sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有  
      success: function (res) {
        // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片  
        var tempFilePaths = res.tempFilePaths;
        console.log('图片路径' + tempFilePaths[0]);
        wx.uploadFile({
          url: 'https://www.sc-xhzt.com/api/image/upload',
          filePath: tempFilePaths[0],
          name: 'file',
          header: {
            "Content-Type": "multipart/form-data",
            'accept': 'application/json',
          },
          formData: {
            'file': tempFilePaths[0],
            'uid': 1,
          },
          success: function (res) {
            let json = res.data.trim();
            let arr = JSON.parse(json);
            that.setData({
              bgImg: arr.data.url,
            })
          },
          fail: function (res) {
            console.log('上传失败' + res.data);
            wx.showToast({
              title: '上传失败',
              icon: 'success',
              duration: 1200
            })
          },
        })
      }
    })
  },

  //图片上传2
  uploadImg2: function (e) {
    var that = this;
    wx.chooseImage({
      count: 1, // 默认9  
      sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有  
      sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有  
      success: function (res) {
        // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片  
        var tempFilePaths = res.tempFilePaths;
        console.log('图片路径' + tempFilePaths[0]);
        wx.uploadFile({
          url: 'https://www.sc-xhzt.com/api/image/upload',
          filePath: tempFilePaths[0],
          name: 'file',
          header: {
            "Content-Type": "multipart/form-data",
            'accept': 'application/json',
          },
          formData: {
            'file': tempFilePaths[0],
            'uid': 1,
          },
          success: function (res) {
            let json = res.data.trim();
            let arr = JSON.parse(json);
            that.setData({
              headimg: arr.data.url,
            })
          },
          fail: function (res) {
            console.log('上传失败' + res.data);
            wx.showToast({
              title: '上传失败',
              icon: 'success',
              duration: 1200
            })
          },
        })
      }
    })
  },
  /**
 * formId获取
 */
  submitInfo: function (e) {
    var that = this;
    console.log('表单submitInfo:==================', e);
    console.log('表单id:==================', e.detail.formId);

    post("/user/addFormid", { uid: that.data.uid, form_id: e.detail.formId }).then(data => {
    })
  },
})

